package com.tsd.system.dao;

import com.tsd.common.vo.BatchDeleteLogicVo;
import com.tsd.core.vo.PageBean;
import com.tsd.system.entity.SysResourceExt;
import com.tsd.system.entity.SysRoleExt;
import com.tsd.system.entity.SysUser;
import com.tsd.system.entity.SysUserExt;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;


/**
 * 描述：SysUserMapper
 *
 * @author Hillpool
 * @date 2019/03/12 12:20:51
 */
public interface SysUserMapper {

    SysUser selectByPrimaryKey(Long id);

    Map<String, Object> selectParamsById(Long id);

    SysUserExt selectBySid(String sid);

    SysUserExt selectWithPwdBySid(String sid);

    List<SysUserExt> selectByPage(@Param("params") Map<String, Object> params, @Param("page") PageBean page);

    List<SysUserExt> selectByParams(@Param("params") Map<String, Object> params) throws Exception;

    List<Map<String, Object>> selectParamsByPage(@Param("params") Map<String, Object> params, @Param("page") PageBean page);

    int deleteByPrimaryKey(Long id);

    int insert(SysUser record);

    int insertSelective(SysUser record);

    int updateByPrimaryKey(SysUser record);

    int updateByPrimaryKeySelective(SysUser record);

    SysUserExt selectByLoginId(String login_id);

    int countByLoginId(String login_id);

    List<SysUserExt> selectByMobile(String mobile);

    void updateLoginTime();

    List<SysUserExt> selectByGroupSid(String group_sid);

    List<SysUserExt> selectSysUsersByParams(@Param("params") Map<String, Object> params);

    List<SysUserExt> selectSysUsersByPage(@Param("params") Map<String, Object> params, @Param("page") PageBean page);

    /**
     * 查询处理当前id外的有效登录id数量
     *
     * @param record
     * @return
     */
    int countByLoginIdExcludeId(SysUser record);

    List<SysUserExt> selectValidByGroupList(@Param("groupList") List<String> groupList);

    List<SysUserExt> selectUserByGroupSidAndRole(@Param("params") Map<String, Object> params);

    List<SysUserExt> selectValidByUserList(@Param("userList") List<String> userList);

    void clearDeviceId(SysUser sysUserExt);

    /**
     * 根据设备id清除设备id
     *
     * @param device_id
     */
    void clearByDeviceId(@Param("device_id") String device_id);

    /**
     * 根据device_id获取用户
     *
     * @param device_id
     * @return
     */
    SysUserExt selectByDeviceId(@Param("device_id") String device_id);

    List<SysUserExt> selectUserByRoleSid(@Param("params") Map<String, Object> params);

    List<SysUserExt> selectByRoleList(@Param("role_list") List<SysRoleExt> role_list);

    /**
     * 获取未绑定的用户
     *
     * @param params
     * @return
     */
    List<SysUserExt> findUnBindSysUser(@Param("params") Map<String, Object> params);

    int deleteLogicBySidList(BatchDeleteLogicVo logicVo);

    List<SysUserExt> selectByEntity(SysUserExt userExt);

    SysUserExt selectSysUserByOpenId(@Param("open_id") String open_id);

    List<SysResourceExt> selectUserPermission(@Param("user_sid") String user_sid, @Param("permissionList") List<String> permissionList);

    List<SysUserExt> selectVaildBySidList(@Param("sid_list") List<String> sid_list);

    int countValid();

    int countValidWithoutAdmin();

    void updateLogout(SysUser user);
}
